import React, { useState } from 'react'
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'

import PrivateRoute from './PrivateRoute'
import HomePage from './../pages/HomePage'
import FindPage from './../pages/FindPage'
import CommunityPage from './../pages/CommunityPage'
import My from './../pages/My'
import Tabbar from './../components/Tabbar'
import Login from '../pages/Login/Login'
import Register from '../pages/Login/Register'
export const routes = [
  {
    path: '/',
    name: 'home',
    component: HomePage,
  },
  {
    path: '/find',
    name: 'find',
    component: require('./../pages/FindPage'),
  },
  {
    path: '/community',
    name: 'community',
    component: require('./../pages/CommunityPage'),
  },
  {
    path: '/my',
    name: 'my',
    component: require('./../pages/My'),
  },
  {
    path: '/login',
    name: 'login',
    component: require('./../pages/Login/Login'),
  },
  {
    path: '/register',
    name: 'register',
    component: require('./../pages/Login/Register'),
  },
]

export function Routes() {
  return (
    <Router>
      <Switch>
        <Route exact path="/" component={HomePage} />
        <PrivateRoute path="/find" component={FindPage} />
        <PrivateRoute path="/community" component={CommunityPage} />
        <PrivateRoute path="/my" component={My} />
        <Route path="/login" component={Login} />
        <Route path="/register" component={Register} />
      </Switch>
      <Tabbar />
    </Router>
  )
}
